package cn.boc.factory;

import cn.boc.pojo.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 水果工厂
 */
public class SimpleFruitFactory {
    /**
     * 创建水果
     *
     * @param type 类型
     * @return Fruit
     */
    public static Fruit createFruit(String type) {

        Fruit fruit = null;

        if (type.equals("apple")) {
            fruit = new Apple();
        } else if (type.equals("banana")) {
            fruit = new Banana();
        } else if (type.equals("orange")) {
            fruit = new Orange();
        } else if (type.equals("pear")) {
            fruit = new Pear();
        }

        return fruit;
    }
}
